Add Option

On this page

Description:

This key represents the standard add option entry in a collections_config.*.add_options array.

The value is an object that defines an option available in the + Add button dropdown at the top right of the Collection browser. Standard add options can contain optional name, icon, editor, base_path, collection, schema, and default_content_file keys.

Appears in:
└── collections_config
    └── *
        └── add_options
            └── [*]
                └── Add Option
Type:
Object
Properties:

This key defines a path for files created using an option in the + Add button dropdown.

This path overrides the path for the current Collection and subfolder open in the Collection browser.

This key is useful if you need to specify a specific subfolder within a Collection.

Appears in: Add Option.

Show examplesHide examples

In this example, we want team members in the _posts Collection to create new files in theblog subfolder of the _drafts Collection rather than the current Collection browser they have open. By configuring the base_path value to /../_drafts/blog, new files will be created in a different Collection subfolder (i.e., _drafts) when a team member selects this option from the + Add button dropdown.

Copied to clipboard
collections_config:
  _posts:
    add_options:
      - name: Add draft blog
        icon: post_add
        editor: content
        base_path: /../_drafts/blog
{
  "collections_config": {
    "_posts": {
      "add_options": [
        {
          "name": "Add draft blog",
          "icon": "post_add",
          "editor": "content",
          "base_path": "/../_drafts/blog"
        }
      ]
    }
  }
}

This key defines the Collection for files created using an option in the + Add button dropdown.

This Collections overrides the current Collection open in the Collection browser.

The value for this key should be the key name of a Collection.

By default, this key is the current Collection open in the Collection browser.

Appears in: Add Option.

Show examplesHide examples

In this example, we want team members in the articles Collection to create new files in the new_articles Collection rather than the current Collection browser they have open. By configuring the collection value to new_articles, new files will be created in a different Collection (i.e., new_articles) when a team member selects this option from the + Add button dropdown.

Copied to clipboard
collections_config:
  articles:
    add_options:
      - name: Add articles
        collection: new_articles
        schema: articles
{
  "collections_config": {
    "articles": {
      "add_options": [
        {
          "name": "Add articles",
          "collection": "new_articles",
          "schema": "articles"
        }
      ]
    }
  }
}

This key defines which file CloudCannon should use to populate a file created with an option in the + Add button dropdown.

The value is a string that specifies a file path relative to the root of your repository. This file is used to populate the initial contents of a new file if the Collection defined in add_options.collection has no Schemas configured.

The add_options.schema key will override default_content_file if configured.

Appears in: Add Option.

Show examplesHide examples

In this example, we want CloudCannon to populate the initial contents of new files with event_template.yml.

Copied to clipboard
collections_config:
  events:
    add_options:
      name: Add new event
      collection: upcoming_events
      default_content_file: event_template.yml
{
  "collections_config": {
    "events": {
      "add_options": {
        "name": "Add new event",
        "collection": "upcoming_events",
        "default_content_file": "event_template.yml"
      }
    }
  }
}
editorstring#

This key defines which editing interface CloudCannon will use when you select an option from the + Add button dropdown.

Values can be one of the following: visual, content, or data.

By default, CloudCannon will open the new file in an appropriate editing interface for that file type.

If CloudCannon cannot determine an appropriate editing interface, it will show a warning.

Allowed values: visual content data

Appears in: Add Option.

Show examplesHide examples

In this example, we have configured a standard add option for the people Collection that opens new files in the Data Editor.

Copied to clipboard
collections_config:
  people:
    add_options:
      - name: Add Staff Member
        schema: employee
        icon: face
        editor: data
    schemas:
      employee:
        path: /.cloudcannon/schemas/employee.yml
{
  "collections_config": {
    "people": {
      "add_options": [
        {
          "name": "Add Staff Member",
          "schema": "employee",
          "icon": "face",
          "editor": "data"
        }
      ],
      "schemas": {
        "employee": {
          "path": "/.cloudcannon/schemas/employee.yml"
        }
      }
    }
  }
}
iconstring#

This key defines the icon displayed next to the text for a standard add option in the + Add button dropdown.

The value is a string that specifies an icon name from Google's Material Symbols.

By default, this key uses the icon of the matching Schema if add_options.schema is configured. Otherwise, this key defaults to add.

Allowed values: 123 360 10k 10mp 11mp 12mp 13mp 14mp 15mp 16mp and 3574 more.

Appears in: Add Option.

Show examplesHide examples

In this example, we have configured a standard add option for the people Collection with the custom icon support_agent.

Copied to clipboard
collections_config:
  people:
    add_options:
      - name: Add Contractor
        icon: support_agent
        schema: contractor
        editor: data
    schemas:
      contractor:
        path: /.cloudcannon/schemas/contractor.yml
{
  "collections_config": {
    "people": {
      "add_options": [
        {
          "name": "Add Contractor",
          "icon": "support_agent",
          "schema": "contractor",
          "editor": "data"
        }
      ],
      "schemas": {
        "contractor": {
          "path": "/.cloudcannon/schemas/contractor.yml"
        }
      }
    }
  }
}
namestring#

This key defines the text displayed for a standard add option in the + Add button dropdown.

The value is a string that specifies the label text for the menu item.

By default, this key uses the name of the matching Schema if add_options.schema is configured. Otherwise, this key has no default value.

Appears in: Add Option.

Show examplesHide examples

In this example, we have configured a standard add option for the people Collection with the custom name "Add Staff Member".

Copied to clipboard
collections_config:
  people:
    add_options:
      - name: Add Staff Member
        schema: employee
        icon: face
        editor: data
    schemas:
      employee:
        path: /.cloudcannon/schemas/employee.yml
{
  "collections_config": {
    "people": {
      "add_options": [
        {
          "name": "Add Staff Member",
          "schema": "employee",
          "icon": "face",
          "editor": "data"
        }
      ],
      "schemas": {
        "employee": {
          "path": "/.cloudcannon/schemas/employee.yml"
        }
      }
    }
  }
}
schemastring#

This key defines which Schema CloudCannon should use to populate a file created with a standard add option in the + Add button dropdown.

The value is a string that specifies the key name of a Schema defined in schemas to use as the default content for the new file.

Configuring this key will override add_options.default_content_file.

By default, this key uses the default Schema in the Collection configured in add_options.collection (or the containing collection if collection is not specified), if Schemas are configured for that collection. Otherwise, this key has no default value.

Appears in: Add Option.

Show examplesHide examples

In this example, we have configured a standard add option for the people Collection that uses the employee Schema to populate new files.

Copied to clipboard
collections_config:
  people:
    add_options:
      - name: Add Staff Member
        schema: employee
        icon: face
        editor: data
    schemas:
      employee:
        path: /.cloudcannon/schemas/employee.yml
{
  "collections_config": {
    "people": {
      "add_options": [
        {
          "name": "Add Staff Member",
          "schema": "employee",
          "icon": "face",
          "editor": "data"
        }
      ],
      "schemas": {
        "employee": {
          "path": "/.cloudcannon/schemas/employee.yml"
        }
      }
    }
  }
}
Examples:

In this example, we have configured a standard add option for the people Collection that uses the employee Schema and opens files in the Data Editor.

Copied to clipboard
collections_config:
  people:
    add_options:
      - name: Add Staff Member
        schema: employee
        icon: face
        editor: data
    schemas:
      employee:
        path: /.cloudcannon/schemas/employee.yml
{
  "collections_config": {
    "people": {
      "add_options": [
        {
          "name": "Add Staff Member",
          "schema": "employee",
          "icon": "face",
          "editor": "data"
        }
      ],
      "schemas": {
        "employee": {
          "path": "/.cloudcannon/schemas/employee.yml"
        }
      }
    }
  }
}
Open in a new tab